﻿using System.Data;

namespace _04_简单工厂;

public class 工厂模式
{
    public interface IDao
    {
        IDbConnection GetConnection();
    }

    class MsSqlDao : IDao
    {
        public IDbConnection GetConnection()
        {
            throw new NotImplementedException();
        }
    }

    class MySqlDao : IDao
    {
        public IDbConnection GetConnection()
        {
            throw new NotImplementedException();
        }
    }

    public abstract class AbsFactory
    {
        public abstract IDao Create();
    }

    public  class MsSqlFactory : AbsFactory
    {
        public override IDao Create()
        {
            return new MsSqlDao();
        }
    }

    public  class MySqlFactory : AbsFactory
    {
        public override IDao Create()
        {
            return new MySqlDao();
        }
    }

}